import 'package:yd_eval/generated/json/base/json_convert_content.dart';
import 'package:yd_eval/entity/yd_api_eval_result_entity.dart';

YdApiEvalResultEntity $YdApiEvalResultEntityFromJson(
    Map<String, dynamic> json) {
  final YdApiEvalResultEntity ydApiEvalResultEntity = YdApiEvalResultEntity();
  final YdApiEvalResultResult? result = jsonConvert.convert<
      YdApiEvalResultResult>(json['result']);
  if (result != null) {
    ydApiEvalResultEntity.result = result;
  }
  final String? requestId = jsonConvert.convert<String>(json['requestId']);
  if (requestId != null) {
    ydApiEvalResultEntity.requestId = requestId;
  }
  final String? errorCode = jsonConvert.convert<String>(json['errorCode']);
  if (errorCode != null) {
    ydApiEvalResultEntity.errorCode = errorCode;
  }
  final String? action = jsonConvert.convert<String>(json['action']);
  if (action != null) {
    ydApiEvalResultEntity.action = action;
  }
  return ydApiEvalResultEntity;
}

Map<String, dynamic> $YdApiEvalResultEntityToJson(
    YdApiEvalResultEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['result'] = entity.result?.toJson();
  data['requestId'] = entity.requestId;
  data['errorCode'] = entity.errorCode;
  data['action'] = entity.action;
  return data;
}

extension YdApiEvalResultEntityExtension on YdApiEvalResultEntity {
  YdApiEvalResultEntity copyWith({
    YdApiEvalResultResult? result,
    String? requestId,
    String? errorCode,
    String? action,
  }) {
    return YdApiEvalResultEntity()
      ..result = result ?? this.result
      ..requestId = requestId ?? this.requestId
      ..errorCode = errorCode ?? this.errorCode
      ..action = action ?? this.action;
  }
}

YdApiEvalResultResult $YdApiEvalResultResultFromJson(
    Map<String, dynamic> json) {
  final YdApiEvalResultResult ydApiEvalResultResult = YdApiEvalResultResult();
  final String? refText = jsonConvert.convert<String>(json['refText']);
  if (refText != null) {
    ydApiEvalResultResult.refText = refText;
  }
  final double? pronunciation = jsonConvert.convert<double>(
      json['pronunciation']);
  if (pronunciation != null) {
    ydApiEvalResultResult.pronunciation = pronunciation;
  }
  final double? start = jsonConvert.convert<double>(json['start']);
  if (start != null) {
    ydApiEvalResultResult.start = start;
  }
  final List<YdApiEvalResultResultWords>? words = (json['words'] as List<
      dynamic>?)?.map(
          (e) =>
      jsonConvert.convert<YdApiEvalResultResultWords>(
          e) as YdApiEvalResultResultWords).toList();
  if (words != null) {
    ydApiEvalResultResult.words = words;
  }
  final double? fluency = jsonConvert.convert<double>(json['fluency']);
  if (fluency != null) {
    ydApiEvalResultResult.fluency = fluency;
  }
  final double? speed = jsonConvert.convert<double>(json['speed']);
  if (speed != null) {
    ydApiEvalResultResult.speed = speed;
  }
  final double? integrity = jsonConvert.convert<double>(json['integrity']);
  if (integrity != null) {
    ydApiEvalResultResult.integrity = integrity;
  }
  final String? service = jsonConvert.convert<String>(json['service']);
  if (service != null) {
    ydApiEvalResultResult.service = service;
  }
  final double? overall = jsonConvert.convert<double>(json['overall']);
  if (overall != null) {
    ydApiEvalResultResult.overall = overall;
  }
  final double? end = jsonConvert.convert<double>(json['end']);
  if (end != null) {
    ydApiEvalResultResult.end = end;
  }
  final bool? isFinal = jsonConvert.convert<bool>(json['isFinal']);
  if (isFinal != null) {
    ydApiEvalResultResult.isFinal = isFinal;
  }
  final String? status = jsonConvert.convert<String>(json['status']);
  if (status != null) {
    ydApiEvalResultResult.status = status;
  }
  return ydApiEvalResultResult;
}

Map<String, dynamic> $YdApiEvalResultResultToJson(
    YdApiEvalResultResult entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['refText'] = entity.refText;
  data['pronunciation'] = entity.pronunciation;
  data['start'] = entity.start;
  data['words'] = entity.words?.map((v) => v.toJson()).toList();
  data['fluency'] = entity.fluency;
  data['speed'] = entity.speed;
  data['integrity'] = entity.integrity;
  data['service'] = entity.service;
  data['overall'] = entity.overall;
  data['end'] = entity.end;
  data['isFinal'] = entity.isFinal;
  data['status'] = entity.status;
  return data;
}

extension YdApiEvalResultResultExtension on YdApiEvalResultResult {
  YdApiEvalResultResult copyWith({
    String? refText,
    double? pronunciation,
    double? start,
    List<YdApiEvalResultResultWords>? words,
    double? fluency,
    double? speed,
    double? integrity,
    String? service,
    double? overall,
    double? end,
    bool? isFinal,
    String? status,
  }) {
    return YdApiEvalResultResult()
      ..refText = refText ?? this.refText
      ..pronunciation = pronunciation ?? this.pronunciation
      ..start = start ?? this.start
      ..words = words ?? this.words
      ..fluency = fluency ?? this.fluency
      ..speed = speed ?? this.speed
      ..integrity = integrity ?? this.integrity
      ..service = service ?? this.service
      ..overall = overall ?? this.overall
      ..end = end ?? this.end
      ..isFinal = isFinal ?? this.isFinal
      ..status = status ?? this.status;
  }
}

YdApiEvalResultResultWords $YdApiEvalResultResultWordsFromJson(
    Map<String, dynamic> json) {
  final YdApiEvalResultResultWords ydApiEvalResultResultWords = YdApiEvalResultResultWords();
  final double? pronunciation = jsonConvert.convert<double>(
      json['pronunciation']);
  if (pronunciation != null) {
    ydApiEvalResultResultWords.pronunciation = pronunciation;
  }
  final double? start = jsonConvert.convert<double>(json['start']);
  if (start != null) {
    ydApiEvalResultResultWords.start = start;
  }
  final int? index = jsonConvert.convert<int>(json['index']);
  if (index != null) {
    ydApiEvalResultResultWords.index = index;
  }
  final double? end = jsonConvert.convert<double>(json['end']);
  if (end != null) {
    ydApiEvalResultResultWords.end = end;
  }
  final String? word = jsonConvert.convert<String>(json['word']);
  if (word != null) {
    ydApiEvalResultResultWords.word = word;
  }
  final List<
      YdApiEvalResultResultWordsPhonemes>? phonemes = (json['phonemes'] as List<
      dynamic>?)?.map(
          (e) =>
      jsonConvert.convert<YdApiEvalResultResultWordsPhonemes>(
          e) as YdApiEvalResultResultWordsPhonemes).toList();
  if (phonemes != null) {
    ydApiEvalResultResultWords.phonemes = phonemes;
  }
  return ydApiEvalResultResultWords;
}

Map<String, dynamic> $YdApiEvalResultResultWordsToJson(
    YdApiEvalResultResultWords entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['pronunciation'] = entity.pronunciation;
  data['start'] = entity.start;
  data['index'] = entity.index;
  data['end'] = entity.end;
  data['word'] = entity.word;
  data['phonemes'] = entity.phonemes?.map((v) => v.toJson()).toList();
  return data;
}

extension YdApiEvalResultResultWordsExtension on YdApiEvalResultResultWords {
  YdApiEvalResultResultWords copyWith({
    double? pronunciation,
    double? start,
    int? index,
    double? end,
    String? word,
    List<YdApiEvalResultResultWordsPhonemes>? phonemes,
  }) {
    return YdApiEvalResultResultWords()
      ..pronunciation = pronunciation ?? this.pronunciation
      ..start = start ?? this.start
      ..index = index ?? this.index
      ..end = end ?? this.end
      ..word = word ?? this.word
      ..phonemes = phonemes ?? this.phonemes;
  }
}

YdApiEvalResultResultWordsPhonemes $YdApiEvalResultResultWordsPhonemesFromJson(
    Map<String, dynamic> json) {
  final YdApiEvalResultResultWordsPhonemes ydApiEvalResultResultWordsPhonemes = YdApiEvalResultResultWordsPhonemes();
  final bool? stressDetect = jsonConvert.convert<bool>(json['stressDetect']);
  if (stressDetect != null) {
    ydApiEvalResultResultWordsPhonemes.stressDetect = stressDetect;
  }
  final double? pronunciation = jsonConvert.convert<double>(
      json['pronunciation']);
  if (pronunciation != null) {
    ydApiEvalResultResultWordsPhonemes.pronunciation = pronunciation;
  }
  final String? phoneme = jsonConvert.convert<String>(json['phoneme']);
  if (phoneme != null) {
    ydApiEvalResultResultWordsPhonemes.phoneme = phoneme;
  }
  final double? start = jsonConvert.convert<double>(json['start']);
  if (start != null) {
    ydApiEvalResultResultWordsPhonemes.start = start;
  }
  final double? end = jsonConvert.convert<double>(json['end']);
  if (end != null) {
    ydApiEvalResultResultWordsPhonemes.end = end;
  }
  final bool? judge = jsonConvert.convert<bool>(json['judge']);
  if (judge != null) {
    ydApiEvalResultResultWordsPhonemes.judge = judge;
  }
  final String? calibration = jsonConvert.convert<String>(json['calibration']);
  if (calibration != null) {
    ydApiEvalResultResultWordsPhonemes.calibration = calibration;
  }
  final double? prominence = jsonConvert.convert<double>(json['prominence']);
  if (prominence != null) {
    ydApiEvalResultResultWordsPhonemes.prominence = prominence;
  }
  final bool? stressRef = jsonConvert.convert<bool>(json['stressRef']);
  if (stressRef != null) {
    ydApiEvalResultResultWordsPhonemes.stressRef = stressRef;
  }
  return ydApiEvalResultResultWordsPhonemes;
}

Map<String, dynamic> $YdApiEvalResultResultWordsPhonemesToJson(
    YdApiEvalResultResultWordsPhonemes entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['stressDetect'] = entity.stressDetect;
  data['pronunciation'] = entity.pronunciation;
  data['phoneme'] = entity.phoneme;
  data['start'] = entity.start;
  data['end'] = entity.end;
  data['judge'] = entity.judge;
  data['calibration'] = entity.calibration;
  data['prominence'] = entity.prominence;
  data['stressRef'] = entity.stressRef;
  return data;
}

extension YdApiEvalResultResultWordsPhonemesExtension on YdApiEvalResultResultWordsPhonemes {
  YdApiEvalResultResultWordsPhonemes copyWith({
    bool? stressDetect,
    double? pronunciation,
    String? phoneme,
    double? start,
    double? end,
    bool? judge,
    String? calibration,
    double? prominence,
    bool? stressRef,
  }) {
    return YdApiEvalResultResultWordsPhonemes()
      ..stressDetect = stressDetect ?? this.stressDetect
      ..pronunciation = pronunciation ?? this.pronunciation
      ..phoneme = phoneme ?? this.phoneme
      ..start = start ?? this.start
      ..end = end ?? this.end
      ..judge = judge ?? this.judge
      ..calibration = calibration ?? this.calibration
      ..prominence = prominence ?? this.prominence
      ..stressRef = stressRef ?? this.stressRef;
  }
}